package org.example;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;


@Import(LoadBalancerConfiguration.class)
@Configuration
public class MyGatewayFilterConfiguration {


    @Bean
    public MyGatewayFilter myGatewayFilter() {
        return new MyGatewayFilter();
    }


    @Bean
    public FilterRegistrationBean<MyGatewayFilter> customGatewayFilter(MyGatewayFilter myGatewayFilter) {
        FilterRegistrationBean<MyGatewayFilter> registrationBean = new FilterRegistrationBean<>();

        // 注册你的过滤器
        registrationBean.setFilter(myGatewayFilter);

        // 设置过滤器的顺序，值越大，过滤器越晚执行
        registrationBean.setOrder(Integer.MAX_VALUE);  // 设置为最大值，确保最后执行

        return registrationBean;
    }



}
